#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    vector<vector<int>> generate(int numRows) {
        vector<vector<int>> v;
        v.resize(numRows);
        for (int i = 0; i < numRows; i++)     v[i].resize(i + 1);

        for (int i = 0; i < numRows; i++)
        {
            for (int j = 0; j < v[i].size(); j++)
            {
                v[i].front() = v[i].back() = 1;
                if (v[i][j] != 1)  v[i][j] = v[i - 1][j - 1] + v[i - 1][j];
            }
        }

        return v;
    }
};